package it.getta.vicinometro.utils;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Point;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import com.google.android.maps.Projection;

public class CircleOverlay extends Overlay {
	private int mLatitude;
	private int mLongitude;
	private float mRadius;
	private int mAlpha = 150;
	private int mRed = 0;
	private int mGreen = 0;
	private int mBlue = 255;

	public CircleOverlay(Context context, int latitude, int longitude, float radius) {
		this.mLatitude=latitude;
		this.mLongitude=longitude;
		this.mRadius=radius;
		
	}

	public void setARGB(int a, int r, int g, int b) {
		mAlpha = a;
		mRed = r;
		mGreen = g;
		mBlue = b;
		
	}

	@Override
	public void draw(Canvas canvas, MapView mapView, boolean shadow) {

        super.draw(canvas, mapView, shadow); 
        
        Projection projection = mapView.getProjection();

        Point pt = new Point();
        
		GeoPoint geo = new GeoPoint(mLatitude, mLongitude);

        projection.toPixels(geo,pt); 

        Paint innerCirclePaint;

        innerCirclePaint = new Paint();
        innerCirclePaint.setARGB(mAlpha, mRed, mGreen, mBlue);
        innerCirclePaint.setAntiAlias(true);

        innerCirclePaint.setStyle(Paint.Style.STROKE);

        canvas.drawCircle((float)pt.x, (float)pt.y, mRadius, innerCirclePaint);
        
        Paint fillCirclePaint;

        fillCirclePaint = new Paint();
        fillCirclePaint.setARGB(20, 000, 000, 255);
        fillCirclePaint.setAntiAlias(true);

        fillCirclePaint.setStyle(Paint.Style.FILL);

        canvas.drawCircle((float)pt.x, (float)pt.y, mRadius, fillCirclePaint);
        
       }
}
